package com.thinkgem.jeesite.modules.cms.web.front;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.modules.university.entity.Major;
import com.thinkgem.jeesite.modules.university.entity.University;
import com.thinkgem.jeesite.modules.university.service.UniversityService;
import com.thinkgem.jeesite.modules.university.utils.UniversityUtils;

/**
 * 专业Controller
 * @author 朱俊吉
 * @version 2017-11-25
 */
@Controller
@RequestMapping(value = "${frontPath}/university")
public class FrontUniversityController {
	
	@Autowired
	private UniversityService universityService;
	
	/**
	 * 高校大全
	 * @param article
	 * @return
	 */
	@RequestMapping(value = "complete*${urlSuffix}")
    private String complete(University university, Model model, HttpServletRequest request, HttpServletResponse response){
		if (university == null){
			university = new University();
		}
		//点击第二次取消该条件
		university.setProvinceIdList(UniversityUtils.removeSame(university.getProvinceIdList()));
		university.setTypeValList(UniversityUtils.removeSame(university.getTypeValList()));
		university.setLevelValList(UniversityUtils.removeSame(university.getLevelValList()));
		university.setNatureValList(UniversityUtils.removeSame(university.getNatureValList()));
		university.setSubjectionValList(UniversityUtils.removeSame(university.getSubjectionValList()));
		
		//查询
		Page<University> page = universityService.findCompletePage(new Page<University>(request, response, 10), university);
		
		model.addAttribute("university", university);
		model.addAttribute("page", page);
		return "modules/cms/front/themes/wending/university_complete";
	}
	/**
	 * 学校简介
	 */
	@RequestMapping(value = "intro-{id}${urlSuffix}", method = RequestMethod.GET)
    private String intro(@PathVariable String id, Model model, HttpServletRequest request){
		University university = universityService.get(id);
		model.addAttribute("university", university);
		//页面样式招生计划选中
		model.addAttribute("mPage","1");
		return "modules/cms/front/themes/wending/university_intro";
	}

}
